package com.chrray.position.controller.web;


import com.chrray.position.domain.FdHomeAd;

import com.chrray.position.pojo.dto.BaseIdDto;
import com.chrray.position.pojo.dto.web.FdHomeAdExe;
import com.chrray.position.service.web.WFdHomeAdService;
import com.chrray.position.util.result.PageBean;
import com.chrray.position.util.result.ResponseResult;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import static com.chrray.position.util.result.ResponseResults.PAGE;
import static com.chrray.position.util.result.ResponseResults.success;

/**
 * 首页广告配置表控制器
 *
 * @author lm
 * @since 1.0.1 2024-09-02
 */
@RestController
@RequestMapping("/api/web/advertising")
@Api(tags = "首页广告图")
@AllArgsConstructor
public class WFdHomeAdController {
    @Autowired
    private WFdHomeAdService wFdHomeAdService;


    @GetMapping("/pageList")
    @ApiOperation("列表")
    public ResponseResult<PageBean<FdHomeAd>> pageCheckList(FdHomeAdExe dto) {
        return PAGE(wFdHomeAdService.pageList(dto));
    }


    @GetMapping("/selectById")
    @ApiOperation("查询详情")
    @ApiResponses({
            @ApiResponse(code=200, message = "ok", response = FdHomeAd.class)
    })
    public ResponseResult<FdHomeAd> selectById(BaseIdDto dto){
        return  success(wFdHomeAdService.getById(dto.getId()));
    }

    @GetMapping("/deletedById")
    @ApiOperation(" 删除")
    public ResponseResult deletedById(BaseIdDto dto){
        return  success(wFdHomeAdService.removeById(dto.getId()));
    }

    @PostMapping("/updateById")
    @ApiOperation("编辑")
    @ApiResponses({
            @ApiResponse(code=200, message = "ok", response = FdHomeAd.class)
    })
    public ResponseResult updateById(@RequestBody FdHomeAd entity){
        return  success(wFdHomeAdService.updateById(entity));
    }

    @PostMapping("/save")
    @ApiOperation("添加")
    @ApiResponses({
            @ApiResponse(code=200, message = "ok", response = FdHomeAd.class)
    })
    public ResponseResult save(@RequestBody FdHomeAd entity){
        return  success(wFdHomeAdService.save(entity));
    }
}
